package cn.tedu.boot31.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

//此注解作用: 相当于添加了@Controller注解和
// 每一个里面的方法都添加了@ResponseBody注解
@RestController
public class AxiosController {
    @RequestMapping("/helloAxios")
    public String helloAxios(){
        return "服务器接受到了请求!";
    }
    @RequestMapping("/test01")
    public String test01(String info){
        return "接受到了:"+info;
    }
    @RequestMapping("/bmi")
    public String bmi(float h,float w){
        //计算bmi的值
        float bmi=w/(h*h);
        String info=null;
        if (bmi<18.5){
            info="偏瘦";
        }else if (bmi<24){
            info="正常";
        }else if (bmi<30){
            info="偏胖";
        }else {
            info="胖了";
        }
        return info;
    }@RequestMapping("/check")
    public String check(String username){
        if (username.equals("tom")){
            return "用户名已存在!";
        }else{
            return "用户名可用!";
        }
    }

}
